import {defineStore} from "pinia";
import {ref} from 'vue';
import {loginAPI} from "@/apis/user";

export const useUserStore=defineStore("user",()=> {
        // 获取到
        // const userInfo = ref({});
        const userToken=ref('')
        const getUserInfo=async ({account,pw}:{account:string,pw:string})=>{
            const res=await loginAPI({account,pw});
            // 获取到token值
            console.log(res.data);
           userToken.value=res.data;
        }
        const clearUserToken=()=>{
            userToken.value=''
        }

        return {
            getUserInfo,
            clearUserToken,
            userToken
        };
    },
    {
        persist:true
    }
)